

Create a header and cpp file to the following spec:


typedef struct _TTokenizedValuePair
{
	int m_iName;
	int	m_iValue;
} TTokenizedValuePair;

typedef struct _TTokenizedElement
{
	int						m_iName;
	int						m_iValue;
	TTokenizedValuePair	*	m_vplAttributes;
} TTokenizedElement;

typedef struct _TTokenizedNode
{
	int							m_iName;
	TTokenizedValuePair		*	m_vplAttributes;
	TTokenizedElement		*	m_telElements;
	struct _TTokenizedNode	*	m_tnlNodes;	
} TTokenizedNode;


<basename>.h

#ifndef __<BASENAME>_H__
#define __<BASENAME>_H__

const LPCSTR BTSTR_<TokenValue> = _T("<TokenValue>");
const int BTID_<TokenValue> = <TokenID>;

extern LPCTSTR g_szBtTkns<Basename>[];

#endif // __<BASENAME>_H__

<basename>.cpp

#include "<basename>.h"

LPCTSTR g_szBtTkns<Basename>[] = 
{
	BTSTR_<TokenValue>,
	...,
	<XMLValue>,
	...,
	NULL
};


const TTokenizedNode g_tnl<Basename>[] =
{
	{ <TokenID>, 
	  {  // Attribute Value Pairs (Name Token of -1 terminates list)
	    { -1, -1 }
	  },
	  {  // Elements (Name Token of -1 terminates list)
	    { -1, -1, 
		  { -1, -1 }
		}
	  },
	  // Also, NULL can terminate as well.
	  NULL
	}
};


=========================================================================

Sample "Test" XML file:

<Config Name="test">
 <Main>
  <UseSomething>True</UseSomething>
  <IP Type="Static">192.168.0.1</IP>
 </Main>
 <Preferences>
  <Like>Ice Cream</Like>
  <Like>Chocolate</Like>
  <Like Type="Dark">Chocolate</Like>
  <InnerNode>
   <Testing>True</Testing>
  </InnerNode>
 </Preferences>
</Config>


=========================================================================
Tokens:

"Config"
"Name"
"Main"
"UseSomething"
"IP"
"Type"
"Preferences"
"Like"
"InnerNode"
"Testing"

"test"
"True"
"Static"
"192.168.0.1"
"Ice Cream"
"Chocolate"
"Dark"


const LPCSTR BTSTR_ConfigConfig			= _T("Config");
const LPCSTR BTSTR_ConfigName			= _T("Name");
const LPCSTR BTSTR_ConfigMain			= _T("Main");
const LPCSTR BTSTR_ConfigUseSomething	= _T("UseSomething");
const LPCSTR BTSTR_ConfigIP				= _T("IP");
const LPCSTR BTSTR_ConfigType			= _T("Type");
const LPCSTR BTSTR_ConfigPreferences	= _T("Preferences");
const LPCSTR BTSTR_ConfigLike			= _T("Like");
const LPCSTR BTSTR_ConfigInnerNode		= _T("InnerNode");
const LPCSTR BTSTR_ConfigTesting		= _T("Testing");

const int BTID_ConfigConfig			= 0;
const int BTID_ConfigName			= 1;
const int BTID_ConfigMain			= 2;
const int BTID_ConfigUseSomething	= 3;
const int BTID_ConfigIP				= 4;
const int BTID_ConfigType			= 5;
const int BTID_ConfigPreferences	= 6;
const int BTID_ConfigLike			= 7;
const int BTID_ConfigInnerNode		= 8;
const int BTID_ConfigTesting		= 9;


LPCTSTR g_szBtTknsConfig[] = 
{
	BTSTR_ConfigConfig,
	BTSTR_ConfigName,
	BTSTR_ConfigMain,
	BTSTR_ConfigUseSomething,
	BTSTR_ConfigIP,
	BTSTR_ConfigType,
	BTSTR_ConfigPreferences,
	BTSTR_ConfigLike,
	BTSTR_ConfigInnerNode,
	BTSTR_ConfigTesting,
	_T("test"),				// 10
	_T("True"),				// 11
	_T("Static"),			// 12
	_T("192.168.0.1"),		// 13
	_T("Ice Cream"),		// 14
	_T("Chocolate"),		// 15
	_T("Dark"),				// 16
	NULL
};


const TTokenizedNode g_tnlConfig[] =
{
	{ BTID_ConfigConfig,
	  {  // Attribute Value Pairs (Name Token of -1 terminates list)
	    { BTID_ConfigName, 10 },
		{ -1, -1 }
	  },
	  NULL, // No elements for this node
	  {
		{ BTID_ConfigMain,
		  NULL, // No Attributes
		  {
			{
				BTID_ConfigUseSomething, 11,
				NULL
			},
			{
				BTID_ConfigIP, 13,
				{
					BTSTR_ConfigType, 12
				},
				{ -1, -1 }
			},
			{
				-1, -1,
				NULL
			}
		  },
		  NULL  // No Nodes
		},
		{ BTID_ConfigPreferences,		
		  NULL, // No Attributes
		  {
			{
				BTID_ConfigLike, 14,
				NULL
			},
			{
				BTID_ConfigLike, 15,
				NULL
			},
			{
				BTID_ConfigLike, 15,
				{
					{ BTID_ConfigType, 16 },
					{ -1, -1 }
				}
			},
			{
				-1, -1,
				NULL
			},
		  },
		  { BTSTR_ConfigInnerNode,
			NULL,
			{
				BTID_ConfigTesting, 12,
				NULL
			},
			NULL
		  }
		},
		{ -1,
		  NULL,
		  NULL,
		  NULL
		}
	  }
	}
};




[NodeNameID]
 [AttrNameID] or -1
 [AttrValue]
    :    :
 -1
 [ElementNameID] or -1
 [ElementValueID]
  [AttrNameID] or -1
  [AttrValue]
    :    :
  -1
  :     :
 -1
 [NodeNameID] or -1
  [AttrNameID] or -1
  [AttrValue]
     :    :
  -1
  [ElementNameID] or -1
  [ElementValueID]
   [AttrNameID] or -1
   [AttrValue]
     :    :
   -1
   :     :
  -1
  :     :
 -1



